package com.game.league.task.sub;

import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.game.base.app.base.BaseActivity;
import com.game.base.utils.toast.ToastUtil;
import com.game.league.R;
import com.game.league.databinding.ActivityTaskAsoBinding;
import com.game.league.service.InterfaceMgr;
import com.game.league.task.sub.adapter.TaskSimpleAdapter;
import com.game.league.task.table.Task;
import com.game.league.util.Constants;

import java.util.ArrayList;
import java.util.List;

import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener;

/**
 * ASO任务
 * Created by Su on 2019/6/7.
 */
public class TaskListActivity extends BaseActivity<ActivityTaskAsoBinding> implements View.OnClickListener {
    private TaskSimpleAdapter adapter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_task_aso;
    }

    @Override
    protected void initView() {
        binding.setTitle("任务列表");
        binding.setClick(this);

        binding.recyclerList.setLayoutManager(new LinearLayoutManager(this));
        adapter = new TaskSimpleAdapter(this, null);
        binding.recyclerList.setAdapter(adapter);
    }

    @Override
    protected void initData() {
        InterfaceMgr.getInstance().getTaskList(Constants.TASK_DALY, new FindListener<Task>() {
            @Override
            public void done(List<Task> list, BmobException e) {
                if (list == null || list.isEmpty()) return;
                adapter.setItems((ArrayList<Task>) list);
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.title_left_iv:
                finish();
                break;
        }
    }
}
